package Day11;

import java.util.Scanner;

public class Tesxt {
    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) throws OverAgeException,OverException{
        Girl  g1 = new Girl();
        while (true) {
            try {
                System.out.println("请输入女朋友的姓名(长度在3-10之间)");
                String name = sc.nextLine();
                g1.setName(name);
                System.out.println("请输入女朋友的年龄(范围在18-40之间)");
                String str = sc.nextLine();
                int age = Integer.parseInt(str);
                g1.setAge(age);
                break;
            } catch (OverException e) {
                e.printStackTrace();
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (OverAgeException e) {
                e.printStackTrace();
            }
        }
        System.out.println("女朋友的姓名是"+ g1.getName()+ "女朋友的年龄是" + g1.getAge());


    }
}
